package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface OrderMapper {


    void insert(Orders orders);

    Page<Orders> listOrders(OrdersPageQueryDTO ordersPageQueryDTO);

    @Select("select * from orders where id = #{id}")
    Orders getOrdersById(Long id);

    @Update("update orders set status = #{status} where id = #{id}")
    void updateStatus(Long id, Integer status);


    void updateOrder(Orders orders);

    @Select("select * from orders where number = #{orderNumber}")
    Orders getOrdersByNumber(String orderNumber);

    @Select("select count(*) from orders where status = #{status}")
    Integer countByStatus(Integer status);

    @Select("select * from orders where status = #{status} and order_time < #{localDateTime}")
    List<Orders> selectOutTimeOrder(Integer status, LocalDateTime localDateTime);

    Integer getOrderOverview(LocalDate today, LocalDate tomorrow, Integer status);
}
